DirScanForm Directory Structure Scan Form1 Frame1 3 Click on Begin Scan to Start Label1 Searching: DirDisp BeginBut Begin Scan CancelBut Abort Scan Frame2 Please Select a Directory: FoundBox CanBut Cancel OKBut DriveBox DirBox FileBox SearchList FoundList LastList EndList TopNum} Foundf ThisDrive Valid MakeTreeList Screen MousePointer FileBox Pattern\ SEARCHCRITERIA DriveBox8 ListCountn List> CheckDriveValidU FALSE LoopIt FoundBox% Begin DirBox DirDisp Caption FoundDir AddAny UserChoose DirScanForm1 Frame1 Visible Frame2 Handler ListIndexj ContinueM NoneFound OKBut_Click FoundBox_DblClick CancelBut_Click Form_Load LCenter Width TCenter Height BeginBut_Click BeginBut CancelBut Label1 CanBut_Click DirBox_Change This program was written by Joel Rose, February, 1992 'e I welcome comments, suggestions, and questions at 185 Shelley Ave., Elizabeth, N.J. 07208 * Please use it and distribute it freely! * DirScanForm Description This form, and its code, is intended to scan a system to find all directories, on any drive, that contain a file, or set of files. I use it in the event that a file or files a program needs are not in the expected directory.t This might be the case if the user moved theo files to another directory. It is a general-purpose alternative to a File Not Found Error.a The routine performs the scan, and then returns a value in the FoundDir variable. In the event that more than one directory contains the files in SEARCHCRITERIA, the userr is presented with a list of directories from which one must be chosen. (It would be preferable, of course, to limit SEARCHCRITERIA to something that would only be in one directory if being used this way, i.e. as part of a user- oriented application.)) One point to notice. In the event that more than onee directory is found, a different set of controls appearr on the form. I wanted to limit the size of the form, II wanted these controls to be invisible until needed, and didn't want to create an additional form. So I used the technique of overlapping controls, keeping the currentlyy UNUSED ones' Visible property set to FALSE. When they neededd to be switched, I only need to swap the Visible properties. I hope this routine is useful, both in terms of the finishedd product, and in terms of the techniques used (e.g. over-- lapping controls; use of drive, directory, and file boxes;, use of DoEvents(), etc.). Please address any comments to me at 70254,3254.i Usage Notes The Statement that calls this form must be- DirScanForm.Show 1 {where the 1 means MODAL}- The Project that this form is added to must contain in its Global Module the following statements:n Global FoundDir as String {this variable will hold the found directory upon exit} Global Const SEARCHCRITERIA = "DOS file mask" {where the mask describes the file(s) being searched for, such as *.XYZ}e (Of course, if necessary, this variable can be changede during execution instead of using it as global constant.) On exit, this form unloads itself. The calling code should examine the FoundDir variable for one of the following three conditions: FoundDir = "" ... No directory matched the SEARCHCRITERIA FoundDir = "Aborted" ... User aborted scan FoundDir = anything else ... You have your directory! Declarations 5000 is an arbitrarily chosen- maximum of number of directories MakeTreeList Hourglass Loop once for each drive in system Begin directory structure search Allow screen updating ands detection of mouse operation Aborted" If user cancelledc Ergo FoundDir = "" Here, one was found - go select it automatically OKBut_Click FoundBox_DblClick CancelBut_Click Aborted" Form_Load Initialize in case of repeat searchy BeginBut_Click Scanning, Please Wait ... CanBut_Click Aborted"